package com.ocom.common;


import com.ocom.common.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author lu
 * @description
 * @date 2020年02月18日 15:21
 */
public class SDKUtil {

    public static boolean isCode(String code,String  regularExpression){
        Pattern r = Pattern.compile(regularExpression);
        Matcher m = r.matcher(code);
        return m.matches();
    }

    /**
     * 过滤请求报文中的空字符串或者空字符串
     * @param contentData
     * @return
     */
    public static Map<String, String> filterBlank(Map<String, String> contentData){
        Map<String, String> submitFromData = new HashMap<String, String>();
        Set<String> keyset = contentData.keySet();

        for(String key:keyset){
            String value = contentData.get(key);
            if (StringUtils.isNotBlank(value)) {
                // 对value值进行去除前后空处理
                submitFromData.put(key, value.trim());
            }
        }
        return submitFromData;
    }
}
